import { ContentTypeEnum } from '/@/enums/httpEnum';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  getuser = '/admin-api/system/user/page',
  edituser = '/admin-api/system/user/update',
  adduser = '/admin-api/system/user/create',
  updateUserStatus = '/admin-api/system/user/update-status',
  deleteuser = '/admin-api/system/user/delete',
  resetpwd = '/admin-api/system/user/update-password',
  userRoles = '/admin-api/system/permission/list-user-roles',
  getuserinfo = '/admin-api/system/user/get',
  assignuser = '/admin-api/system/permission/assign-user-role',
  userselect = '/admin-api/system/user/list-all-simple',
  getUserToken = '/admin-api/system/oauth2-token/page',
  deleteUserToken = '/admin-api/system/oauth2-token/delete',
  exportUser = '/admin-api/system/user/export',
  deptList = '/admin-api/system/dept/list',
}
export interface UserExportReqVO {
  code?: string;
  name?: string;
  status?: number;
  createTime?: Date[];
}
/**
 * @description: 获用户
 */
export const getDeptList = (params: any) => {
  return defHttp.get<any>({ url: Api.deptList, params }, { withToken: false, withUserId: false });
};
export const getuser = (params: any) => {
  return defHttp.get<any>({ url: Api.getuser, params }, { withToken: false, withUserId: false });
};
export const adduser = (params: any) => {
  return defHttp.post<any>({ url: Api.adduser, params });
};
export const edituser = (params: any) => {
  return defHttp.put<any>({ url: Api.edituser, params });
};
export const updateUserStatus = (params: any) => {
  return defHttp.put<any>({ url: Api.updateUserStatus, params });
};
export const deleteuser = (params: any) => {
  return defHttp.delete<any>(
    { url: Api.deleteuser, params, headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED } },
    { joinParamsToUrl: true },
  );
};
export const resetpwd = (params: any) => {
  return defHttp.put<any>({ url: Api.resetpwd, params });
};
// export const getuserlistnopage = (params: any) => {
//   return defHttp.get<any>({ url: Api.getuserlistnopage, params });
// };
export const listUserRoles = (params: any) => {
  return defHttp.get<any>({ url: Api.userRoles, params });
};
export const getUser = (params: any) => {
  return defHttp.get<any>({ url: Api.getuserinfo, params });
};
export const assignUserRole = (params: any) => {
  return defHttp.post<any>({ url: Api.assignuser, params });
};
export const userSelect = (params: any) => {
  return defHttp.get<any>({ url: Api.userselect, params });
};
export const getUserToken = (params: any) => {
  return defHttp.get<any>({ url: Api.getUserToken, params });
};
export const deleteUserToken = (params: any) => {
  return defHttp.delete<any>({
    url: Api.deleteUserToken,
    params,
    headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED },
  });
};
export function exportUser(params: UserExportReqVO) {
  return defHttp.download({ url: Api.exportUser, params }, '用户.xls');
}
